﻿using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using HHControls.CreditEducation.Properties;

namespace HHControls.CreditEducation
{
    public class HHMainForm : Form
    {
        public HHMainForm()
        {
            InitializeForm();
        }

        private void InitializeForm()
        {
            BackColor = Color.White;
            Text = "Credit Education Supporter";
            DoubleBuffered = true;
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
            base.OnPaintBackground(e);
            CreateBackgroundImage(e.Graphics, ClientSize.Width, ClientSize.Height);
        }

        private static void CreateBackgroundImage(Graphics g, int width, int height)
        {
            var textureBrush = new TextureBrush(Resources.left, WrapMode.Tile);
            g.FillRectangle(textureBrush, 0, 0, 214, height);

            textureBrush = new TextureBrush(Resources.top, WrapMode.Tile);
            g.FillRectangle(textureBrush, 0, 0, width, 38);

            textureBrush = new TextureBrush(Resources.dot, WrapMode.Tile);
            g.FillRectangle(textureBrush, width - 13, 0, 13, height);
            g.FillRectangle(textureBrush, 0, height - 26, width, 26);

            g.DrawImage(Resources.corner_top_left, 0, 0, 215, 164);
            g.DrawImage(Resources.corner_bottom_left, 0, height - 75, 242, 75);
            g.DrawImage(Resources.corner_bottom_right, width - 114, height - 37, 114, 37);
            g.DrawImage(Resources.corner_top_right, width - 261, 0, 261, 104);

            g.DrawImage(Resources.arrow_left, 230, 40, 260, 37);
            g.DrawImage(Resources.arrow_right, width - 256, 40, 173, 34);
        }

        protected override void OnClientSizeChanged(EventArgs e)
        {
            Invalidate();
            base.OnClientSizeChanged(e);
        }
    }
}